import http from '../../common/http'
Page({
    data: {
        // 定义轮播图图片资源
        img: [
            '../../imgs/b1.jpg',
            '../../imgs/b2.jpg',
            '../../imgs/b3.jpg',
            '../../imgs/b4.jpg',
            '../../imgs/b5.jpg',
        ],
        list: null,
        isShow:true
    },
    onLoad(options) {
        wx.showLoading({
            title: '加载中...',
          })
        wx.setNavigationBarTitle({
          title: options.title,
        })
        let a = wx.getStorageSync('nameList')
        if (a) {
            this.setData({
                list: a,
                isShow:false
            });
            wx.hideLoading({
                success: (res) => {},
              })
        } else {
            let obj = {
                url: '/1700-2?showapi_appid=985280&showapi_sign=59608625ed8243edbb9de8740853d3f3&classifyId=' + options.classifyId
            };
            http(obj).then(res => {
                wx.setStorageSync('nameList', res.data.showapi_res_body.contentlist);
                this.setData({
                    list: res.data.showapi_res_body.contentlist,
                    isShow:false
                })
            });
            wx.hideLoading({
                success: (res) => {},
              })
        }
    },
    jump(e) {
        let id = e.currentTarget.dataset.id
        wx.navigateTo({
            url: '../detail/detail?id=' + id + '&title=' + e.currentTarget.dataset.name,
        })
    }


})